class Game:
    def __init__(self, frog, fox, trap):
        self.frog = frog
        self.fox = fox
        self.trap = list(range(0, frog * fox * trap, trap))

    def start(self):
        for i in self.trap[1:]:
            if (i % self.fox) == (i % self.frog) == 0:
                return print('both')
            if i % self.frog == 0:
                return print('frog')
            if i % self.fox == 0:
                return print('fox')

while True:
    frog,fox,trap = eval(input("输入参数:"))
    gg = Game(frog, fox, trap)
    gg.start()
